package com.scenery.server.services;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;



public class Manager {
	public static Connection getConnectionBy()
	{
		Connection con =null;
		try {
			Class.forName(Constans.DRIVER);
			con = DriverManager.getConnection(Constans.URL,Constans.USER,Constans.PWD);
			
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		

		return con;
		
	}
	public static Connection getConnection()
	{
		Connection con =null;
		String driver="",url="",user="",pwd="";
		try {
			//InputStream in = ClassLoader.getSystemResourceAsStream("db.properties");
			InputStream in =new FileInputStream(new File("d:\\db.properties"));
			java.util.Properties p=new java.util.Properties();
			p.load(in);
			driver=p.getProperty("DRIVER");
			url=p.getProperty("URL");
			user=p.getProperty("USER");
			pwd=p.getProperty("PWD");
			Class.forName(driver);
			con = DriverManager.getConnection(url,user,pwd);
			
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		

		return con;
		
	}
	public static void p(Object o)
	{
		System.out.println(o);
		InputStream in = ClassLoader.getSystemResourceAsStream("db.properties");
		java.util.Properties p=new java.util.Properties();
		try {
			p.load(in);
			System.out.println(p.getProperty("PWD"));
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		
	}
	public static void main(String args[]){
		//System.out.println(p(""));
		p("");
	}
}
